package idv.loveloser.mobilemoodle;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SectionAdapter extends BaseAdapter{
	private Context mContext;
	private String[] sectionStr;
	private LayoutInflater SectionHolder;
	private LayoutInflater mInflater;
	public SectionAdapter(Context context){
		this.mContext=context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return sectionStr.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		SectionHolder holder =null;
		this.mInflater = LayoutInflater.from(mContext); 
		if (convertView == null) {
			holder=new SectionHolder();   
			convertView = mInflater.inflate(R.layout.section_list_holder, null);
			holder.title=  (TextView) convertView.findViewById(R.id.sectionTitle);
			
			convertView.setTag(holder); 
		}else{
			holder = (SectionHolder)convertView.getTag(); 
		}
		holder.title.setText(this.sectionStr[position]);
		
		return convertView;
	}
	public String[] getSectionStr() {
		return sectionStr;
	}
	public void setSectionStr(String[] sectionStr) {
		this.sectionStr = sectionStr;
	}

}
